package com.skstudio.report;

import java.math.BigInteger;

public class ReportBase {

    public static final int cMaxQueueOffline = 28800; // 8 hour offline
    public static final int cMaxQueueOnline = 900; // 15min online
    static int mMaxQueueSize = cMaxQueueOnline;

    public static int getMaxQueueSize() {
        return mMaxQueueSize;
    }

    public static void setMaxQueueSize(boolean isLive) {
        mMaxQueueSize = isLive ? cMaxQueueOnline : cMaxQueueOffline;
    }

    public static long getCxxUnsignedLong(byte[] buffer, int offset) {
        long nRC = 0;
        for (int i = 3; i >= 0; i--) {
            nRC <<= 8;
            int temp = buffer[offset + i];
            if (temp < 0) {
                temp = 0x100 + temp;
            }
            nRC += temp;
        }
        return nRC;
    }

    public static void setCxxUnsignedLong(byte[] buffer, int offset, long value) {
        for (int i = 0; i < 4; i++) {
            byte temp = (byte) (value & 0xff);
            buffer[offset + i] = temp;
            value >>= 8;
        }
    }

    public static BigInteger getCxxUnsignedLongLong(byte[] buffer, int offset) {
        BigInteger nRC = new BigInteger("0");
        for (int i = 7; i >= 0; i--) {
            nRC = nRC.shiftLeft(8);
            int temp = buffer[offset + i];
            if (temp < 0) {
                temp = 0x100 + temp;
            }
            nRC = nRC.add(new BigInteger(Integer.toString(temp)));
        }
        return nRC;
    }

    public void parse(byte[] buffer, int offset) {
    }

    public void reset() {
    }

    public static int mRecordCount = 0;

    public int getRecordCount() {
        return mRecordCount;
    }
}
